﻿
@{
    Layout = "~/Views/Shared/_AddEdit.cshtml";
}

@section header{
    <script type="text/javascript">
        function SaveBeforeCallBack() {
            var Ssum = 0;
            var Esum = 0;
            if ($("#_CourseName").val() == '') {
                layer.msg('温馨提示：必须填写课程名称~！~'); return true;
            }
            if ($("#_StuNumber").val() == '') {
                layer.msg('温馨提示：必须填写学员人数~！~'); return true;
            }
            if ($("#_Dperiod").val() == '') {
                layer.msg('温馨提示：必须填写扣课时数~！~'); return true;
            }
            if ($("#_Account").val() == '') {
                layer.msg('温馨提示：必须填写金额~！~'); return true;
            }
            if ($("#Ssui").val() == '' && $("#Ssui").val() > 1 && $("#Syue").val() == '' && $("#Syue").val() > 1) {
                layer.msg('温馨提示：必须填写开始岁数并大于1~！~'); return true;
            }
            else {
                Ssum = (parseInt($("#Ssui").val()) * 12) + parseInt($("#Syue").val());
                $("#_StartMonth").val(Ssum)
            }
            if ($("#Esui").val() == '' && $("#Esui").val() > 1 && $("#Eyue").val() == '' && $("#Eyue").val() > 1) {
                layer.msg('温馨提示：必须填写结束岁数并大于1~！~'); return true;
            }
            else {
                Esum = (parseInt($("#Esui").val()) * 12) + parseInt($("#Eyue").val());
                $("#_EndMonth").val(Esum)
            }
            if (Ssum > Esum) {
                ayer.msg('温馨提示：必须开始年龄不能大于结束年龄~！~'); return true;
            }
        }
    </script>
}

<input type="hidden" name="_CreateId" id="_CreateId" value="@ViewBag.data["CreateId"]" />
<input type="hidden" name="_State" id="_State" value="@ViewBag.data["State"]" />
<input type="hidden" name="_Createdate" id="_Createdate" value="@ViewBag.data["Createdate"]" />
<input type="hidden" name="_LeagueId" id="_LeagueId" value="@ViewBag.data["LeagueId"]" />
<input type="hidden" id="_IsOrder" name="_IsOrder" value="@ViewBag.data["IsOrder"]">
<input type="hidden" id="_IsTentative" name="_IsTentative" value="@ViewBag.data["IsTentative"]">
<input type="hidden" id="_StartMonth" name="_StartMonth" value="@ViewBag.data["StartMonth"]">
<input type="hidden" id="_EndMonth" name="_EndMonth" value="@ViewBag.data["EndMonth"]">
<div style=" margin-top:20px;"></div>
<div class="layui-col-md12">
    <div class="layui-card">
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color:red">*</span><span style="margin-left:0.5rem">课程名称</span></label>
            <div class="layui-input-block">
                <input type="text" id="_CourseName" name="_CourseName" placeholder="请输入课程名称" class="layui-input" style="width:30rem" value="@ViewBag.data["CourseName"]">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color:red">*</span><span style="margin-left:0.5rem">学员人数</span></label>
            <div class="layui-input-inline">
                <input type="number" id="_StuNumber" name="_StuNumber" placeholder="请输入人数" class="layui-input" style="width:10rem" value="@ViewBag.data["StuNumber"]">
            </div>
            <div class="layui-form-mid layui-word-aux">人</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="margin-left:0.5rem">约课</span></label>
            <div class="layui-input-inline">
                <input type="checkbox" id="" name="" lay-skin="switch" lay-filter="IsOrder" title="开关" value="1" @(ViewBag.data["IsOrder"] == 1 ? "checked='checked'" : "")>
            </div>
            <label class="layui-form-label"><span style="margin-left:0.5rem">试听</span></label>
            <div class="layui-input-inline">
                <input type="checkbox" id="" name="" lay-skin="switch" lay-filter="IsTentative" title="开关" value="0" @(ViewBag.data["IsTentative"] == 0 ? "checked='checked'" : "")>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="margin-left:0.5rem">状态</span></label>
            <div class="layui-input-inline">
                <input type="checkbox" id="" name="" lay-skin="switch" lay-filter="State" title="开关" value="1" @(ViewBag.data["State"] == 0 ? "checked='checked'" : "")>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color:red">*</span><span style="margin-left:0.5rem">扣课时数</span></label>
            <div class="layui-input-inline">
                <input type="number" id="_Dperiod" name="_Dperiod" placeholder="请输入时数" class="layui-input" style="width:10rem" value="@ViewBag.data["Dperiod"]">
            </div>
            <div class="layui-form-mid layui-word-aux">课时</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color:red">*</span><span style="margin-left:0.5rem">起始年龄</span></label>
            <div class="layui-input-inline">
                <input type="number" id="Ssui" placeholder="请输入多少岁" class="layui-input" style="width:10rem">
            </div>
            <div class="layui-form-mid layui-word-aux">岁</div>
            <div class="layui-input-inline">
                <input type="number" id="Syue" placeholder="请输入月" class="layui-input" style="width:10rem">
            </div>
            <div class="layui-form-mid layui-word-aux">月</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color:red">*</span><span style="margin-left:0.5rem">终止年龄</span></label>
            <div class="layui-input-inline">
                <input type="number" id="Esui" placeholder="请输入多少岁" class="layui-input" style="width:10rem">
            </div>
            <div class="layui-form-mid layui-word-aux">岁</div>
            <div class="layui-input-inline">
                <input type="number" id="Eyue" placeholder="请输入月" class="layui-input" style="width:10rem">
            </div>
            <div class="layui-form-mid layui-word-aux">月</div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="_Remark" placeholder="请输入内容" class="layui-textarea" style="min-height:100px;min-width:300px;">@ViewBag.data["Remark"]</textarea>
            </div>
        </div>


    </div>
</div>


<script src="../Layui/layui.js"></script>

<script>
    layui.config({
        base: '../Layui/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use('index');
</script>

<script>
    layui.use(['form', 'laydate'], function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#BirdDate' //指定元素
            , value: new Date()
        });


    });
</script>
<script>
    layui.use('form', function () {
        var form = layui.form;
        //各种基于事件的操作，下面会有进一步介绍
        //监听指定开关
        form.on('switch(IsOrder)', function (data) {
            //layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
            //    offset: '6px'
            //});
            if (this.checked) {
                $("#_IsOrder").val("1");
            }
            else {
                $("#_IsOrder").val("0");
            }
        });
        //监听指定开关
        form.on('switch(IsTentative)', function (data) {
            if (this.checked) {
                $("#_IsTentative").val("0");
            }
            else {
                $("#_IsTentative").val("1");
            }
        });

        //监听指定开关
        form.on('switch(State)', function (data) {
            if (this.checked) {
                $("#_State").val("0");
            }
            else {
                $("#_State").val("1");
            }
        });
    })
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
@section layui{

    if (@ViewBag.Lx== 1)//编辑状态赋值数据。岁月数据，字段名一致就可以自动赋值。不一致要自己转换，.Lx==1表示编辑状态
    {
        var StartMonth =@ViewBag.data["StartMonth"];
        var EndMonth=@ViewBag.data["EndMonth"];
        if (StartMonth) {

            $("#Ssui").val(parseInt(StartMonth / 12));
            $("#Syue").val(parseInt(StartMonth % 12));
        }
        if (EndMonth) {
            $("#Esui").val(parseInt(EndMonth / 12));
            $("#Eyue").val(parseInt(EndMonth % 12));
        }
    }
}
</script>
